package com.woniuxy.propertyjava.controller;

import com.woniuxy.propertyjava.entity.PageBean;
import com.woniuxy.propertyjava.entity.Registered;
import com.woniuxy.propertyjava.entity.ResponseResult;
import com.woniuxy.propertyjava.entity.ShopMessage;
import com.woniuxy.propertyjava.service.RegisteredService;
import com.woniuxy.propertyjava.service.ShopMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class ShopMessageController {

    @Autowired
    private ShopMessageService shopMessageService;

    //路径变量参数
    //条件查询+分页
    @PostMapping("/shopmessage/{pageIndex}/{pageSize}")
    public ResponseResult<PageBean<ShopMessage>>
        getAllShopByLimit(@PathVariable("pageIndex") int pageIndex,
                             @PathVariable("pageSize") int pageSize,
                             @RequestBody ShopMessage shopMessage){
        System.out.println("查询条件："+shopMessage);
        System.out.println("pageIndex："+pageIndex);
        System.out.println("pageSize："+pageSize);
        PageBean<ShopMessage> pageBean= shopMessageService.getqueryAllShopByLimit(shopMessage,pageIndex,pageSize);
        ResponseResult<PageBean<ShopMessage>> responseResult=
                new ResponseResult<>(200,"ok",pageBean);
        return responseResult;
    }

    //添加人员
    @PostMapping("/shopmessage")
    public ResponseResult addShop(@RequestBody ShopMessage shopMessage){
        System.out.println("添加人员"+shopMessage);
        shopMessageService.getinsert(shopMessage);
        return new ResponseResult<>(200, "添加成功", null);
    }

    //修改人员
    @PutMapping("/shopmessage")
    public ResponseResult modifyShop(@RequestBody ShopMessage shopMessage){
        System.out.println("修改人员"+shopMessage);
        shopMessageService.getupdate(shopMessage);
        return new ResponseResult<>(200, "修改成功", null);
    }

    //删除人员
    @DeleteMapping("/shopmessage/{sid}")
    public ResponseResult removeShop(@PathVariable("sid") int sid){
        System.out.println("删除人员"+sid);
        shopMessageService.getdeleteById(sid);
        return new ResponseResult<>(200, "删除成功", null);
    }






}
